use "long_data_ready_for_analysis.dta", clear

*support across issues
bys caseid: gen first_obs = _n == 1
bys Question: tab Support

*average salience2
bys caseid: egen salience_ave = mean(issue_salience)
bys caseid: gen salience_demean = issue_salience - salience_ave

*importance across issues (proprtion of variance)
bys Question: tab issue_salience
xtset caseid 
xtsum issue_salience if inlist(condition, 1, 2, 3)
display .8255354^2 / (.8255354^2 + .5432828^2)



*TABLE A1
gen independent = pid7 == 4
gen included = issue_salience != . & Support != .

ttest issue_salience if (self == 1 | libtrump == 1) & included == 1, by(libtrump)
ttest issue_salience if (self == 1 | contrump == 1) & included == 1, by(contrump)

ttest race_white if (self == 1 | libtrump == 1) & included == 1, by(libtrump)
ttest race_white if (self == 1 | contrump == 1) & included == 1, by(contrump)

ttest male if (self == 1 | libtrump == 1) & included == 1, by(libtrump)
ttest male if (self == 1 | contrump == 1) & included == 1, by(contrump)

ttest knowledge if (self == 1 | libtrump == 1) & included == 1, by(libtrump)
ttest knowledge if (self == 1 | contrump == 1) & included == 1, by(contrump)

ttest trump_favor if (self == 1 | libtrump == 1) & included == 1, by(libtrump)
ttest trump_favor if (self == 1 | contrump == 1) & included == 1, by(contrump)

ttest ideo5b if (self == 1 | libtrump == 1) & included == 1, by(libtrump)
ttest ideo5b if (self == 1 | contrump == 1) & included == 1, by(contrump)

ttest party_strength if (self == 1 | libtrump == 1) & included == 1, by(libtrump)
ttest party_strength if (self == 1 | contrump == 1) & included == 1, by(contrump)

ttest income if (self == 1 | libtrump == 1) & included == 1, by(libtrump)
ttest income if (self == 1 | contrump == 1) & included == 1, by(contrump)

ttest educ if (self == 1 | libtrump == 1) & included == 1, by(libtrump)
ttest educ if (self == 1 | contrump == 1) & included == 1, by(contrump)

ttest newsint if (self == 1 | libtrump == 1) & included == 1 & newsint != 5, by(libtrump)
ttest newsint if (self == 1 | contrump == 1) & included == 1 & newsint != 5, by(contrump)

ttest republican if (self == 1 | libtrump == 1) & included == 1, by(libtrump)
ttest republican if (self == 1 | contrump == 1) & included == 1, by(contrump)

ttest democrat if (self == 1 | libtrump == 1) & included == 1, by(libtrump)
ttest democrat if (self == 1 | contrump == 1) & included == 1, by(contrump)

ttest independent if (self == 1 | libtrump == 1) & included == 1, by(libtrump)
ttest independent if (self == 1 | contrump == 1) & included == 1, by(contrump)

ttest age if (self == 1 | libtrump == 1) & included == 1, by(libtrump)
ttest age if (self == 1 | contrump == 1) & included == 1, by(contrump)

tab self libtrump if included == 1
tab self contrump if included == 1





**********************************************
*TABLE A2: Replication of Results in Barber and Pope (2019)
regress Support contrump libtrump

*by party 
regress Support libtrump contrump if republican == 1
regress Support libtrump contrump if democrat == 0 & republican == 0
regress Support libtrump contrump if democrat == 1

*political knowledge
regress Support i.contrump##c.knowledge i.libtrump##c.knowledge 

*party strength
regress Support i.contrump##c.party_strength i.libtrump##c.party_strength  if inlist(pid7, 4, 5, 6, 7)

*trump approval
regress Support i.contrump##c.trump_favor i.libtrump##c.trump_favor 

*ideology
regress Support i.contrump##c.ideo5b i.libtrump##c.ideo5b 





**********************************************
*TABLE A3: Average Treatment Effect Interacted With Issue Importance
*simple interaction - Model 1
regress Support i.libtrump##c.issue_salience i.contrump##c.issue_salience, cluster(Question)

*Model 2 - include individual fixed effects - accounts for average level of caring for each person
areg Support i.libtrump##c.issue_salience i.contrump##c.issue_salience, absorb(caseid) cluster(Question)

*Model 3 - include question fixed effects - accounts for aveage level of caring for each question
areg Support i.libtrump##c.issue_salience i.contrump##c.issue_salience, absorb(Question) cluster(caseid)

*Model 4 - control for mean importance rather than fixed effect
regress Support i.libtrump##c.issue_salience i.contrump##c.issue_salience salience_ave, cluster(Question)

*Model 5 - control for mean importance and include question fixed effect
areg Support i.libtrump##c.issue_salience i.contrump##c.issue_salience salience_ave, absorb(Question) cluster(caseid)

*Model 6 - include question and individual fixed effect
areg Support i.Question i.libtrump##c.issue_salience i.contrump##c.issue_salience, absorb(caseid) cluster(Question)

*Model 7 - include control variables
regress Support i.libtrump##c.issue_salience i.contrump##c.issue_salience knowledge party_strength trump_favor ideo5b republican democrat, cluster(Question)

*Model 8 - include control variables with question fixed effects
areg Support i.libtrump##c.issue_salience i.contrump##c.issue_salience knowledge party_strength trump_favor ideo5b, absorb(Question) cluster(caseid)

*Model 9 - demeaned salience, include control variables with question fixed effects
areg Support i.libtrump##c.salience_demean i.contrump##c.salience_demean knowledge party_strength trump_favor ideo5b, absorb(Question) cluster(caseid)




**********************************************
*TABLE A4: Liberal Trump Treatment by Party Identification

*liberal treatment
gen pid3_indy = pid3
replace pid3_indy = 3 if pid3 == 4
replace pid3_indy = 3 if pid3 == 5
label values pid3_indy pid3

*Model 1 - all together with pid3
regress Support i.libtrump##c.issue_salience##i.pid3_indy if contrump == 0, cluster(Question)

*these margins values get entered into .cvs file "party_interaction_models_margins.csv"
*democrat
margins, dydx(libtrump) at(issue_salience=(1(1)5) pid3_indy=(1))
*republican
margins, dydx(libtrump) at(issue_salience=(1(1)5) pid3_indy=(2))
*independent
margins, dydx(libtrump) at(issue_salience=(1(1)5) pid3_indy=(3))

*Model 2 - include individual fixed effects - accounts for average level of caring for each person
areg Support i.libtrump##c.issue_salience##i.pid3_indy if contrump == 0, cluster(Question) absorb(caseid)

*Model 3 - include question fixed effects - accounts for aveage level of caring for each question
areg Support i.libtrump##c.issue_salience##i.pid3_indy if contrump == 0, cluster(Question) absorb(Question)

*Model 4 - control for mean support rather than fixed effect
regress Support i.libtrump##c.issue_salience##i.pid3_indy salience_ave if contrump == 0, cluster(Question)

*Model 5 - control for mean support and include question fixed effect
areg Support i.libtrump##c.issue_salience##i.pid3_indy salience_ave if contrump == 0, cluster(caseid) absorb(Question)

*Model 6 - include question and individual fixed effect
areg Support i.Question i.libtrump##c.issue_salience##i.pid3_indy if contrump == 0, cluster(Question) absorb(caseid)

*Model 7 - include control variables
regress Support i.libtrump##c.issue_salience##i.pid3_indy knowledge party_strength trump_favor ideo5b if contrump == 0, cluster(Question)

*Model 8 - include control variables with question fixed effects
regress Support i.libtrump##c.issue_salience##i.pid3_indy knowledge party_strength trump_favor ideo5b if contrump == 0, cluster(Question) absorb(Question)



**********************************************
*TABLE A4: Liberal Trump Treatment by Party Identification

*Conservative Treatment
*Model 1 - all together with pid3
regress Support i.contrump##c.issue_salience##i.pid3_indy if libtrump == 0, cluster(caseid)

*these margins values get entered into .cvs file "party_interaction_models_margins_conservative.csv"
*democrat
margins, dydx(contrump) at(issue_salience=(1(1)5) pid3_indy=(1))
*republican
margins, dydx(contrump) at(issue_salience=(1(1)5) pid3_indy=(2))
*independent
margins, dydx(contrump) at(issue_salience=(1(1)5) pid3_indy=(3))

*Model 2 - include individual fixed effects - accounts for average level of caring for each person
areg Support i.contrump##c.issue_salience##i.pid3_indy if libtrump == 0, cluster(Question) absorb(caseid)

*Model 3 - include question fixed effects - accounts for aveage level of caring for each question
areg Support i.contrump##c.issue_salience##i.pid3_indy if libtrump == 0, cluster(Question) absorb(Question)

*Model 4 - control for mean support rather than fixed effect
regress Support i.contrump##c.issue_salience##i.pid3_indy salience_ave if libtrump == 0, cluster(Question)

*Model 5 - control for mean support and include question fixed effect
areg Support i.contrump##c.issue_salience##i.pid3_indy salience_ave if libtrump == 0, cluster(caseid) absorb(Question)

*Model 6 - include question and individual fixed effect
areg Support i.Question i.contrump##c.issue_salience##i.pid3_indy if libtrump == 0, cluster(Question) absorb(caseid)

*Model 7 - include control variables
regress Support i.contrump##c.issue_salience##i.pid3_indy knowledge party_strength trump_favor ideo5b if libtrump == 0, cluster(Question)

*Model 8 - include control variables with question fixed effects
regress Support i.contrump##c.issue_salience##i.pid3_indy knowledge party_strength trump_favor ideo5b if libtrump == 0, cluster(Question) absorb(Question)




**********************************************
*TABLE A6: "placebo" test - salience by average salience per question, not by respondent
bys Question: egen salience_ave_q = mean(issue_salience)

*Model 1
regress Support i.libtrump##c.salience_ave_q i.contrump##c.salience_ave_q, cluster(Question)
*Model 2
areg Support i.libtrump##c.salience_ave_q i.contrump##c.salience_ave_q, absorb(caseid) cluster(Question)
*Model 3
areg Support i.libtrump##c.salience_ave_q i.contrump##c.salience_ave_q, absorb(Question) cluster(caseid)
*Model 4
regress Support i.libtrump##c.salience_ave_q i.contrump##c.salience_ave_q salience_ave, cluster(Question)
*Model 5
regress Support i.libtrump##c.salience_ave_q i.contrump##c.salience_ave_q salience_ave, absorb(Question) cluster(Question)
*Model 6
areg Support i.Question i.libtrump##c.salience_ave_q i.contrump##c.salience_ave_q, absorb(caseid) cluster(Question)
*Model 7
regress Support i.libtrump##c.salience_ave_q i.contrump##c.salience_ave_q knowledge party_strength trump_favor ideo5b, cluster(Question)
*Model 8
areg Support i.libtrump##c.salience_ave_q i.contrump##c.salience_ave_q knowledge party_strength trump_favor ideo5b, absorb(Question) cluster(caseid)




**********************************************
*TABLE A7: nonlinear interaction (break into three groups of roughly equal size)
areg Support libtrump contrump if inlist(issue_salience, 1, 2, 3), absorb(caseid) cluster(Question)
areg Support libtrump contrump if issue_salience == 4,absorb(caseid)  cluster(Question)
areg Support libtrump contrump if issue_salience == 5,absorb(caseid)  cluster(Question)

areg Support i.Question libtrump contrump if inlist(issue_salience, 1, 2, 3), absorb(caseid) cluster(Question)
areg Support i.Question libtrump contrump if issue_salience == 4,absorb(caseid)  cluster(Question)
areg Support i.Question libtrump contrump if issue_salience == 5,absorb(caseid)  cluster(Question)



**********************************************
*TABLE A8: Results with Subsets of Importance - By Within-Respondent Issue Importance Variation
bys caseid: egen salience_sd = sd(issue_salience)
sum salience_sd if first_obs == 1, d

*nonlinear interaction (break into three groups of roughly equal size based on salience variation)
regress Support libtrump contrump if salience_sd < .503, absorb(caseid) cluster(caseid)
regress Support libtrump contrump if salience_sd >= .503 & salience_sd < 1.04, absorb(caseid) cluster(caseid)
regress Support libtrump contrump if salience_sd >= 1.04, absorb(caseid) cluster(caseid)

regress Support i.Question libtrump contrump if salience_sd < .503, absorb(caseid) cluster(caseid)
regress Support i.Question libtrump contrump if salience_sd >= .503 & salience_sd < 1.04, absorb(caseid) cluster(caseid)
regress Support i.Question libtrump contrump if salience_sd >= 1.04, absorb(caseid) cluster(caseid)




**********************************************
*TABLE A9: Results Omitting Respondents Who Gave Same Issue Importance for All Issues
tab caseid if salience_sd != 0 & first_obs == 1
tab caseid if salience_sd == 0 & first_obs == 1
display 75/1552
*4.832474 PERCENT OF PEOPLE GAVE SAME RESPONSE FOR ALL ISSUES

*Model 1
regress Support i.libtrump##c.issue_salience i.contrump##c.issue_salience if salience_sd != 0, cluster(Question)
*Model 2
areg Support i.libtrump##c.issue_salience i.contrump##c.issue_salience if salience_sd != 0, absorb(caseid) cluster(Question)
*Model 3
areg Support i.libtrump##c.issue_salience i.contrump##c.issue_salience if salience_sd != 0, absorb(Question) cluster(caseid)
*Model 4
regress Support i.libtrump##c.issue_salience i.contrump##c.issue_salience salience_ave if salience_sd != 0, cluster(Question)
*Model 5
regress Support i.libtrump##c.issue_salience i.contrump##c.issue_salience salience_ave if salience_sd != 0, absorb(Question) cluster(Question)
*Model 6
areg Support i.Question i.libtrump##c.issue_salience i.contrump##c.issue_salience if salience_sd != 0, absorb(caseid) cluster(Question)
*Model 7
regress Support i.libtrump##c.issue_salience i.contrump##c.issue_salience knowledge party_strength trump_favor ideo5b if salience_sd != 0, cluster(Question)
*Model 8
areg Support i.libtrump##c.issue_salience i.contrump##c.issue_salience knowledge party_strength trump_favor ideo5b if salience_sd != 0, absorb(Question) cluster(caseid)




**********************************************
*TABLE A10: Models Omitting `Don't Know' Responses

*Model 1
regress Support i.libtrump##c.issue_salience i.contrump##c.issue_salience if Support != 0, cluster(Question)
*Model 2
areg Support i.libtrump##c.issue_salience i.contrump##c.issue_salience if Support != 0, absorb(caseid) cluster(Question)
*Model 3
areg Support i.libtrump##c.issue_salience i.contrump##c.issue_salience if Support != 0, absorb(Question) cluster(caseid)
*Model 4
regress Support i.libtrump##c.issue_salience i.contrump##c.issue_salience salience_ave if Support != 0, cluster(Question)
*Model 5
regress Support i.libtrump##c.issue_salience i.contrump##c.issue_salience salience_ave if Support != 0, absorb(Question) cluster(Question)
*Model 6
areg Support i.Question i.libtrump##c.issue_salience i.contrump##c.issue_salience if Support != 0, absorb(caseid) cluster(Question)
*Model 7
regress Support i.libtrump##c.issue_salience i.contrump##c.issue_salience knowledge party_strength trump_favor ideo5b if Support != 0, cluster(Question)
*Model 8
areg Support i.libtrump##c.issue_salience i.contrump##c.issue_salience knowledge party_strength trump_favor ideo5b if Support != 0, absorb(Question) cluster(caseid)




**********************************************
*TABLE A11: Predicting Salience
gen ideology_folded = abs(ideo5b - 3)
regress salience_ave knowledge republican democrat party_strength trump_favor ideology_folded if first_obs == 1




**********************************************
*TABLE A12: Testing for Survey Demand Effects

*Model 1 - first question
regress Support libtrump contrump issue_salience knowledge party_strength trump_favor ideo5b if Question == 1
*Model 2 - questions 2 through 5
regress Support libtrump contrump issue_salience knowledge party_strength trump_favor ideo5b if Question >1 & Question <= 5
*Model 3 - questions 6 through 20
regress Support libtrump contrump issue_salience knowledge party_strength trump_favor ideo5b if Question > 5
